//
//  WSPurchaseManager.h
//  CharonTVProject
//
//  Created by karong on 2023/8/10.
//

#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
NS_ASSUME_NONNULL_BEGIN
@class WSPurchaseManager;
@protocol WSPurchaseManagerDelegate <NSObject>

/**
 成功收到苹果的商品响应
 */
- (void)didAppleReceiveResponse;

/**
 需要弹窗的类型，也可以理解为订单状态
 */
- (void)purchaseManager:(WSPurchaseManager *)manager updateStatus:(WSPurchaseStatus)status object:(id)object;

@end

@interface WSPurchaseManager : NSObject
SingletonH
// coins VIP
@property (nonatomic, strong) NSArray *products;
@property (nonatomic, weak) id<WSPurchaseManagerDelegate> delegate;
// 应用商店推荐位来的订单
@property (nonatomic, strong) NSString *storeProductId;
// 最后一次购买的id
@property (nonatomic, strong) NSString *lastPaymentId;
/**
 购买商品
 
 @param product 商品
 */
- (void)addProduct:(SKProduct *)product paymentId:(NSString *)paymentId;

/**
 还原订单
 */
- (void)restoreWithIsChange:(Boolean)isChange block:(charonTV_BoolBlock)block;

/**
 完成订单
 */
- (void)completeTransactions:(NSArray<SKPaymentTransaction *> *)transactions;

/// 校验最后一次订单
- (void)retryVerifyTransaction;

- (void)createOrderWithProduct:(id)product;
@end

NS_ASSUME_NONNULL_END
